home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr37
/
satsfaxt.zip
/
CCPUTILS.ZIP
/
ERROR.C
< prev
next >
Wrap
Text File
|
1990-01-30
|
13KB
|
182 lines
/*===========================================================================*
* *
* ERROR.C *
* *
*---------------------------------------------------------------------------*
* *
* This module prints an error message corresponding to the error *
* number sent to it. Additionally, fatal errors will cause a termination *
* of the program returning the exit code associated with the error *
* message to DOS. *
* *
* CALL : void CASError(int errornumber, int fatal, char *caller, *
* int hwerrornumber); *
* RETURN : none (exit code returned to DOS on fatal errors) *
* *
* The following source code is intended to assist developers in *
* creating applications which support the DCA/Intel Communicating *
* Applications Specification Version 1.0A. It is provided free of charge *
* and on an as-is basis. THE IMPLIED WARRENTIES OF MERCHANTABILITY AND *
* FITNESS FOR A PARTICULAR PURPOSE ARE SPECIFICALLY EXCLUDED. This source *
* code may be modified, enhanced, copied and distributed with applications *
* that support CAS on a royalty free basis. *
* *
*---------------------------------------------------------------------------*
* *
* HISTORY: *
* - completed 9/14/89 *
* *
*===========================================================================*/
#include <stdio.h>
/*---------------------------------------------------------------------------*
* CASError *
*---------------------------------------------------------------------------*
* This function prints an application error message. If there is a CAS *
* error associated with the error, it too is printed out. Finally, if *
* the error is fatal, the program is terminated with the proper exit code. *
*---------------------------------------------------------------------------*
* INPUT : error number, fatal indicator, calling process, CAS error #. *
* OUTPUT: exit code if fatal. *
*---------------------------------------------------------------------------*/
#include <dos.h>
#include "cas.h"
#include "util.h"
#define UpperBound(a) (sizeof(a)/sizeof(a[0]))
/* Application errors and exit codes. */
ERRORMSG ErrorMsg[] = {
{ 0, ""},
{ 2, "CCAM not loaded, Resident manager must be installed prior to using this utility." }, /* CASNOHWO */
{ 2, "CCAM not loaded, Resident manager must be installed prior to using this utility." }, /* CASNOHWN */
{ 3, "Not enough memory - unload some TSRs or reduce BUFFERS in CONFIG.SYS." }, /* CASNOMEM */
{ 2, "Cannot run diagnostics while board is active. Try again later." }, /* CASDIAG */
{ 2, "Hardware error." }, /* CASHW */
{ 2, "Error sending file." }, /* CASSEND */
{ 2, "An error was encountered while trying to get the External Data Block." }, /* CASNOEDB */
{ 2, "Cannot open Task Control File - check the task number and try again." }, /* CASNOTCF */
{ 2, "Cannot open Receive Control File - check the task number and try again." }, /* CASNORCF */
{ 2, "Cannot open Log Control File - check the task number and try again." }, /* CASNOLCF */
{ 3, "Cannot create temporary file - check disk space available." }, /* CASCREATETEMP */
{ 3, "Cannot open temporary file." }, /* CASOPENTEMP */
{ 1, "Invalid date specified - be sure to give date as mm/dd/yy (month/day/year)." }, /* CASBADDATE */
{ 1, "Invalid time specified - be sure to give time as hh/mm ((24)hour/minute)." }, /* CASBADTIME */
{ 1, "You must specify at least one file name." }, /* CASARGFILE */
{ 1, "You must specify a path name." }, /* CASARGPATH */
{ 1, "Only one path name can be specified." }, /* CASARGMULTPATH */
{ 2, "Unable to cancel pending event." }, /* CASNOCAN */
{ 2, "No currently executing event to cancel." }, /* CASNOEVENT */
{ 2, "Error encountered while trying to delete the Task Queue." }, /* CASDELTQ */
{ 2, "Error encountered while trying to delete the Log Queue." }, /* CASDELLQ */
{ 2, "Error encountered while trying to delete the Receive Queue." }, /* CASDELRQ */
{ 2, "Cannot delete event - check the task number and try again." }, /* CASDELJOB */
{ 3, "Cannot open cover page file - check the path and filename and try again." }, /* CASOPENCOVER */
{ 3, "Cannot move file - check disk space available." }, /* CASMOVE */
{ 3, "Specified path must exist - create the directory and try again." }, /* CASNOPATH */
{ 3, "Unable to change current directory." }, /* CASNODIR */
{ 3, "Unable to retreive current directory." }, /* CASNOCURDIR */
{ 3, "Unable to load/unload FREIZE - make sure FRIEZE.UTL is in the connect dir." }, /* CASNOFREIZE */
{ 0, "NOT USED IN THIS VERSION." }, /* CASBADPORT */
{ 0, "NOT USED IN THIS VERSION." }, /* CASBADDRIVER */
{ 1, "Invalid switch specified on command line - check and try again (/? for help)." }, /* CASBADARG */
{ 2, "Unable to determine Autoreceive State - make sure CCAM is correctly installed." }, /* CASBADARS */
{ 3, "Cannot redirect output to specified file - check disk space available." }, /* CASBADREDIR */
{ 3, "Cannot determine current working directory." }, /* CASBADCWD */
{ 1, "Event specified is not a File Transfer - check event number and try again." }, /* CASNOTFT */
{ 1, "Event specified is not a Fax - check event number and try again." }, /* CASNOTFAX */
{ 3, "Cannot open log output file." }, /* CASBADLF */
{ 1, "Specified file(s) not PCX, DCX, or ASCII - cannot FAX binary file." }, /* CASBADFAXFILE */
{ 1, "Logo files must be of PCX type - specify correct file and try again." }, /* CASBADLOGOFILE */
{ 1, "Cover files must be of ASCII type - specify correct file and try again." }, /* CASBADCOVERFILE */
{ 1, "Cannot find specified file(s) - check names and try again." }, /* CASBADFILEARG */
{ 1, "Cannot find ASCII file." }, /* CASOPENASCII */
{ 1, "Cannot find PCX file." }, /* CASOPENPCX */
{ 1, "Cannot find DCX file." }, /* CASOPENDCX */
{ 2, "The specified file has already been saved." }, /* CASPRIORMOVE */
{ 2, "Nothing found to save."}, /* CASNOMOVE */
{ 2, "Unable to cancel current event."}, /* CASNOCUR */
{ 3, "Printer timed out - check power to printer and try again." }, /* CASNOPRINTER */
{ 3, "Printer I/O error - check printer and try again." }, /* CASBADIO */
{ 3, "Printer out of paper." } /* CASNOPAPER */
};
/* CAS errors (exit code field is the CAS error number). */
ERRORMSG CASErrorMsg[] = {
{ 0x0000, "" },
{ 0x0002, "Image file is corrupted." },
{ 0x0003, "File was sent, but it might contain errors." },
{ 0x0004, "Receive data lost." },
{ 0x0005, "Invalid or missing logofile." },
{ 0x0006, "File name doesn't match NSF header." },
{ 0x0007, "File size doesn't match NSF header." },
{ 0x0200, "Internal error. Task switch failed." },
{ 0x0201, "Unknown command.." },
{ 0x0202, "Event not found." },
{ 0x0203, "Tried to findnext with previous findfirst." },
{ 0x0204, "No more events." },
{ 0x0207, "Unknown schedule division." },
{ 0x0208, "Bad event control file." },
{ 0x0209, "Connection CoProcessor is busy." },
{ 0x020A, "Invalid PCAM parameter." },
{ 0x020B, "Can't uninstall PCAM." },
{ 0x020C, "File already exists." },
{ 0X0280, "Unknown task type." },
{ 0X0281, "Bad phone number." },
{ 0X0282, "Bad .PCX file header." },
{ 0X0283, "Unexpected end of file." },
{ 0X0284, "Phone line disconnected during event." },
{ 0x0285, "Exceeded maximum dialing retries." },
{ 0X0286, "No files specified to send." },
{ 0X0287, "Connection CoProcessor isn't responding." },
{ 0X0288, "More than 1023 pages of receive data." },
{ 0X0289, "Manual connect posted too long ago." },
{ 0X028A, "Connection CoProcessor command set error." },
{ 0X028B, "Bad NSF header file." },
{ 0X0401, "Remote unit not Group 3 compatible." },
{ 0X0402, "Remote unit didn't send its capabilities." },
{ 0X0403, "Remote unit requested disconnect." },
{ 0X0404, "Remote unit isn't a CCP." },
{ 0X0405, "Exceeded retrain or fax resend limit." },
{ 0X0406, "Line noise or CCP & remote don't agree on bit rate." },
{ 0X0407, "Remote unit disconnected after receiving data." },
{ 0X0408, "No reply from remote unit after sending data." },
{ 0X0409, "Capabilities of remote unit aren't compatible." },
{ 0X040B, "Invalid reply from remote unit after sending data." },
{ 0X040D, "Phone line dead or remote unit disconnected." },
{ 0X0411, "Invalid command from remote after receiving data." },
{ 0X0415, "Tried to receive from incompatible hardware." },
{ 0X041F, "Unexpected end of file while receiving." },
{ 0X045C, "Receive buffer overflowed while receiveing." },
{ 0X045D, "Remote unit unexpectedly stopped sending data." },
{ 0X045E, "Remote unit didn't send any data." },
{ 0X045F, "Remote unit took too long to send fax scan line." },
{ 0X0463, "Can't get through to remote unit." },
{ 0X0464, "User canceled event." }
};
void CASError(int ErrorNumber, int Fatal, int HwENumber, int Action)
{
int x;
/* Print the application error message. */
fprintf(stderr, "%s\n", ErrorMsg[ErrorNumber].Message );
/* If a CAS error was specified, look it up and print it! */
if(HwENumber != 0) {
for(x = 1; x < UpperBound(CASErrorMsg); x++) {
if(CASErrorMsg[x].ExitCode == HwENumber) {
fprintf(stderr, "%s\n", CASErrorMsg[x].Message);
break;
}
}
}
/* If error was fatal, exit with DOS exit code. */
if(Fatal)
exit(ErrorMsg[ErrorNumber].ExitCode);
}